<template>
  <div class="index">
    <van-nav-bar left-text="爱课">
      <template #right>
        <img :src="url" alt="" @click="popup" />
      </template>
    </van-nav-bar>
    <!-- lunbo -->
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="(item, index) in swperlist" :key="index">
        <img :src="item" alt="" />
      </van-swipe-item>
    </van-swipe>
    <!-- 推荐课程 -->
    <van-nav-bar>
      <template #left>
        <img :src="url3" alt="" />
        <span style="font-size: 20px; margin-left: 5px; font-weight: 700"
          >推荐课程</span
        >
      </template>
    </van-nav-bar>
    <!-- 推荐课程 -->
    <div class="got">
      <div class="got-top">
        <p>5天哈弗外教体验营</p>
        <span> <b></b> </span>
      </div>
      <p class="ccc">每天25分钟，认识75%的单词</p>
      <div class="flag-100">
        <span>每日限量100</span>
      </div>
      <div><button>0元领取</button></div>
    </div>
    <!-- 推荐阅读 -->
    <div class="read">
      <van-nav-bar>
        <template #left>
          <b></b>
          <span style="font-size: 20px; margin-left: 5px; font-weight: 700"
            >推荐阅读</span
          >
        </template>
      </van-nav-bar>
      <ul>
        <li v-for="item in readlist" :key="item.id">
          <img :src="item.img" alt="" />
          <div>
            <p>{{ item.title }}</p>
            <p class="fz-14">{{ item.content }}</p>
            <span>育儿启示</span>
          </div>
        </li>
      </ul>
    </div>
    <!-- 爱课介绍 -->
    <div class="aike">
      <van-nav-bar>
        <template #left>
          <b></b>
          <span style="font-size: 20px; margin-left: 5px; font-weight: 700"
            >爱课介绍</span
          >
        </template>
      </van-nav-bar>
      <ul>
        <li>
          <a href="https://oss.aircourses.com/web/ac_home/teacher-video.mp4">
            <img :src="tu5" alt="" />
          </a>
        </li>
        <li>
          <a
            href="https://f.video.weibocdn.com/003y5hNVgx07BhKhEYZ901041200nogc0E010.mp4?label=mp4_1080p&template=1920x1080.25.0&trans_finger=706238e13862eac9158714b62b2988d4&media_id=4476659383074838&tp=8x8A3El:YTkl0eM8&us=0&ori=1&bf=4&ot=h&ps=3lckmu&uid=3ZoTIp&ab=3915-g1,5178-g0,966-g1&Expires=1631539434&ssig=UpfJN%2BCAgo&KID=unistore,video"
          >
            <img :src="tu4" alt="" />
          </a>
        </li>
        <li>
          <a href="https://oss.aircourses.com/web/ac_home/home-video.mp4">
            <img :src="tu3" alt="" />
          </a>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import url from "../../assets/images/形状 1.png";
import url2 from "../../assets/images/图层 1.png";
import url3 from "../../assets/images/形状 2.png";
import url4 from "../../assets/images/图层 2.png";
import tu5 from "../../assets/images/图层 5.png";
import tu4 from "../../assets/images/图层 4.png";
import tu3 from "../../assets/images/图层 3.png";
// 引入依赖
import { NavBar, Dialog, Swipe, SwipeItem } from "vant";
import { computed, onMounted } from "vue";
import { useStore } from "vuex";
export default {
  components: { vanNavBar: NavBar, vanSwipe: Swipe, vanSwipeItem: SwipeItem },
  setup() {
    // swper
    const store = useStore();
    const swperlist = computed(() => {
      return store.state.index.swperlist;
    });
    onMounted(() => {
      store.dispatch("getswperlistAsync");
    });

    // read
    const { readlist } = readmoduld();

    // 客服模块
    const { popup } = kefu();

    return {
      popup,
      url,
      url2,
      url3,
      url4,
      tu5,
      tu3,
      tu4,

      readlist,
      swperlist,
    };
  },
};
// 客服模块
const kefu = () => {
  const popup = () => {
    Dialog.alert({
      // title: "",
      message: "亲，项目还未上线，客服功能暂未开启",
      theme: "round-button",
    }).then(() => {
      // on close
    });
  };
  return { popup };
};

// 推荐阅读模块的接口引入
const readmoduld = () => {
  const store = useStore();
  const readlist = computed(() => {
    return store.state.index.readlist;
  });
  onMounted(() => {
    store.dispatch("getreadAsync");
  });
  return { readlist };
};
// 编程式导航-跳转到详情页的
</script>
<style lang="less" scoped>
.index {
  width: 100%;
  height: 100%;
  overflow: auto;
  margin-bottom: 98px;
  // padding: 0 16px;
}
// 头部
.van-nav-bar {
  margin-top: 20px;
  // width: 375px;
  // height: 100%;
  /deep/.van-nav-bar__text {
    font-size: 20px !important;
    color: black;
    font-weight: 700;
  }
  img {
    width: 30px;
    height: 25px;
  }
}
// 轮播
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  // line-height: 150px;
  text-align: center;
  // background-color: #39a9ed;
  img {
    width: 100%;
    height: 211px;
  }
}
// 领取
.got {
  padding: 5px 16px;
  border-radius: 20px;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.2);
  .got-top {
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    p {
      line-height: 70px;
    }
    span {
      width: 70px;
      height: 70px;
      font-size: 14px;
      font-weight: 900;
      color: white;
      background: url("../../assets/images/矩形 2.png");

      b {
        display: inline-block;
        width: 45px;
        height: 45px;
        // transform: rotate(45deg);
        background: url("../../assets/images/牛妈 推荐.png") no-repeat;
        background-size: cover;
        transform: translate(24px, 3px);
      }
    }
  }
  .ccc {
    font-size: 18px;
    color: #666;
    padding: 0 16px;
  }
  .flag-100 {
    padding: 15px 16px;
    span {
      font-size: 14px;
      background-color: rgba(191, 24, 32, 0.2);
      color: #cd444c;
    }
  }
  button {
    display: block;
    width: 100%;
    line-height: 50px;
    padding: 0 16px;
    margin-bottom: 10px;
    background-color: crimson;
    color: white;
    border: 0;
    border-radius: 20px;
    font-size: 14px;
  }
}
// read
.read {
  b {
    display: inline-block;
    width: 25px;
    height: 25px;
    background: url("../../assets/images/组 2(1).png") no-repeat;
    background-size: cover;
  }
  ul {
    padding: 0 16px;
    li {
      display: flex;
      position: relative;
      padding: 20px 16px;
      border-bottom: 3px dashed #ccc;

      img {
        width: 70px;
        height: 70px;
        margin-right: 10px;
      }
      p {
        font-size: 16px;
        line-height: 25px;
      }
      .fz-14 {
        font-size: 13px;
        color: #666;
        width: 230px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      span {
        font-size: 13px;
        position: absolute;
        right: 0;
        bottom: 0;
        color: #32dfff;
        margin-bottom: 10px;
      }
    }
  }
}
// 爱课
.aike {
  b {
    display: inline-block;
    width: 25px;
    height: 25px;
    background: url("../../assets/images/组 5(1).png") no-repeat;
    background-size: cover;
  }
  ul {
    display: flex;
    padding: 0 16px;
    li {
      margin-right: 5px;
      img {
        width: 110px;
        height: 130px;
      }
    }
  }
}
</style>
